SHELL = /bin/sh

#### Start of system configuration section. ####

srcdir = @srcdir@
VPATH = @srcdir@:@srcdir@/missing

CC = @CC@
YACC = @YACC@
PURIFY =
AUTOCONF = autoconf
@SET_MAKE@

prefix = @prefix@
CFLAGS = @CFLAGS@ -I. -I@srcdir@ -I@includedir@
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
XLDFLAGS = @XLDFLAGS@
EXTLIBS = 
LIBS = @LIBS@ $(EXTLIBS)
MISSING = @LIBOBJS@ @ALLOCA@
LDSHARED = @LIBRUBY_LDSHARED@
DLDFLAGS = @LIBRUBY_DLDFLAGS@
SOLIBS = @SOLIBS@

RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@
EXEEXT = @EXEEXT@
PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)

#### End of system configuration section. ####

MAJOR=	@MAJOR@
MINOR=	@MINOR@
TEENY=	@TEENY@

LIBRUBY_A     = @LIBRUBY_A@
LIBRUBY_SO    = @LIBRUBY_SO@
LIBRUBY_ALIASES= @LIBRUBY_ALIASES@
LIBRUBY	      = @LIBRUBY@
LIBRUBYARG    = @LIBRUBYARG@

EXTOBJS	      = 

MAINOBJ	      = main.@OBJEXT@

OBJS	      = array.@OBJEXT@ \
		bignum.@OBJEXT@ \
		class.@OBJEXT@ \
		compar.@OBJEXT@ \
		dir.@OBJEXT@ \
		dln.@OBJEXT@ \
		enum.@OBJEXT@ \
		error.@OBJEXT@ \
		eval.@OBJEXT@ \
		file.@OBJEXT@ \
		gc.@OBJEXT@ \
		hash.@OBJEXT@ \
		inits.@OBJEXT@ \
		io.@OBJEXT@ \
		marshal.@OBJEXT@ \
		math.@OBJEXT@ \
		numeric.@OBJEXT@ \
		object.@OBJEXT@ \
		pack.@OBJEXT@ \
		parse.@OBJEXT@ \
		process.@OBJEXT@ \
		prec.@OBJEXT@ \
		random.@OBJEXT@ \
		range.@OBJEXT@ \
		re.@OBJEXT@ \
		regex.@OBJEXT@ \
		ruby.@OBJEXT@ \
		signal.@OBJEXT@ \
		sprintf.@OBJEXT@ \
		st.@OBJEXT@ \
		string.@OBJEXT@ \
		struct.@OBJEXT@ \
		time.@OBJEXT@ \
		util.@OBJEXT@ \
		variable.@OBJEXT@ \
		version.@OBJEXT@ \
		$(MISSING)

all:		miniruby$(EXEEXT) rbconfig.rb
		@./miniruby$(EXEEXT) -Xext extmk.rb @EXTSTATIC@

miniruby$(EXEEXT):	config.status $(LIBRUBY_A) $(MAINOBJ) dmyext.@OBJEXT@
		@rm -f $@
		$(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) dmyext.@OBJEXT@ $(LIBRUBY_A) $(LIBS) -o $@

$(PROGRAM):     $(LIBRUBY) $(MAINOBJ) $(EXTOBJS) 
		@rm -f $@
		$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@

$(LIBRUBY_A):	$(OBJS) dmyext.@OBJEXT@
		@AR@ rcu $@ $(OBJS) dmyext.@OBJEXT@
		@-@RANLIB@ $@ 2> /dev/null || true

$(LIBRUBY_SO):	$(OBJS) dmyext.@OBJEXT@
		$(LDSHARED) $(DLDFLAGS) $(SOLIBS) $(OBJS) dmyext.@OBJEXT@ -o $@
		@-./miniruby -e 'ARGV.each{|link| File.delete link if File.exist? link; \
						  File.symlink "$(LIBRUBY_SO)", link}' \
				$(LIBRUBY_ALIASES) || true

install:	rbconfig.rb
		./miniruby$(EXEEXT) $(srcdir)/instruby.rb $(DESTDIR)

clean:;		@rm -f $(OBJS) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES) $(MAINOBJ) rbconfig.rb
		@rm -f ext/extinit.c ext/extinit.@OBJEXT@ dmyext.@OBJEXT@
		@-./miniruby$(EXEEXT) -Xext extmk.rb clean 2> /dev/null || true
		@rm -f $(PROGRAM) miniruby$(EXEEXT)

distclean:	clean
		@rm -f Makefile ext/extmk.rb config.h
		@rm -f ext/config.cache config.cache config.log config.status
		@rm -f *~ core *.core gmon.out y.tab.c y.output ruby.imp

realclean:	distclean
		@rm -f parse.c
		@rm -f lex.c

test:		miniruby$(EXEEXT)
		@./miniruby$(EXEEXT) $(srcdir)/rubytest.rb

rbconfig.rb:	miniruby$(EXEEXT)
		@./miniruby$(EXEEXT) $(srcdir)/mkconfig.rb rbconfig.rb

config.status:	$(srcdir)/configure
		$(SHELL) ./config.status --recheck

$(srcdir)/configure: $(srcdir)/configure.in
		cd $(srcdir) && $(AUTOCONF)

.c.@OBJEXT@:
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<

lex.c: keywords
	gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ @srcdir@/keywords > lex.c

parse.c: parse.y
	$(YACC) $<
	mv -f y.tab.c parse.c

alloca.@OBJEXT@: @srcdir@/missing/alloca.c
	$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/alloca.c

crypt.@OBJEXT@: @srcdir@/missing/crypt.c
	$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/crypt.c

dup2.@OBJEXT@: @srcdir@/missing/dup2.c
	$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/dup2.c

finite.@OBJEXT@: @srcdir@/missing/finite.c
	$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/finite.c

flock.@OBJEXT@: @srcdir@/missing/flock.c
	$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/flock.c

isinf.@OBJEXT@: @srcdir@/missing/isinf.c
	$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/isinf.c

isnan.@OBJEXT@: @srcdir@/missing/isnan.c
	$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/isnan.c

fnmatch.@OBJEXT@: @srcdir@/missing/fnmatch.c
	$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/fnmatch.c

memcmp.@OBJEXT@: @srcdir@/missing/memcmp.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/memcmp.c

memmove.@OBJEXT@: @srcdir@/missing/memmove.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/memmove.c

mkdir.@OBJEXT@: @srcdir@/missing/mkdir.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/mkdir.c

vsnprintf.@OBJEXT@: @srcdir@/missing/vsnprintf.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/vsnprintf.c

strcasecmp.@OBJEXT@: @srcdir@/missing/strcasecmp.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strcasecmp.c

strncasecmp.@OBJEXT@: @srcdir@/missing/strncasecmp.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strncasecmp.c

strchr.@OBJEXT@: @srcdir@/missing/strchr.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strchr.c

strdup.@OBJEXT@: @srcdir@/missing/strdup.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strdup.c

strerror.@OBJEXT@: @srcdir@/missing/strerror.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strerror.c

strftime.@OBJEXT@: @srcdir@/missing/strftime.c
	$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strftime.c

strstr.@OBJEXT@: @srcdir@/missing/strstr.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strstr.c

strtod.@OBJEXT@: @srcdir@/missing/strtod.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtod.c

strtol.@OBJEXT@: @srcdir@/missing/strtol.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtol.c

strtoul.@OBJEXT@: @srcdir@/missing/strtoul.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtoul.c

nt.@OBJEXT@: @srcdir@/missing/nt.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/nt.c

x68.@OBJEXT@: @srcdir@/missing/x68.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/x68.c

os2.@OBJEXT@: @srcdir@/missing/os2.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/os2.c

dl_os2.@OBJEXT@: @srcdir@/missing/dl_os2.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/dl_os2.c

# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:
###
parse.@OBJEXT@: parse.y ruby.h config.h defines.h intern.h env.h node.h st.h regex.h util.h lex.c
###
array.@OBJEXT@: array.c ruby.h config.h defines.h intern.h
bignum.@OBJEXT@: bignum.c ruby.h config.h defines.h intern.h
class.@OBJEXT@: class.c ruby.h config.h defines.h intern.h node.h st.h
compar.@OBJEXT@: compar.c ruby.h config.h defines.h intern.h
dir.@OBJEXT@: dir.c ruby.h config.h defines.h intern.h
dln.@OBJEXT@: dln.c config.h defines.h dln.h
dmyext.@OBJEXT@: dmyext.c
enum.@OBJEXT@: enum.c ruby.h config.h defines.h intern.h
error.@OBJEXT@: error.c ruby.h config.h defines.h intern.h env.h
eval.@OBJEXT@: eval.c ruby.h config.h defines.h intern.h node.h env.h rubysig.h st.h dln.h
file.@OBJEXT@: file.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h
gc.@OBJEXT@: gc.c ruby.h config.h defines.h intern.h rubysig.h st.h node.h env.h re.h regex.h
hash.@OBJEXT@: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h util.h
inits.@OBJEXT@: inits.c ruby.h config.h defines.h intern.h
io.@OBJEXT@: io.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h env.h
main.@OBJEXT@: main.c ruby.h config.h defines.h intern.h
marshal.@OBJEXT@: marshal.c ruby.h config.h defines.h intern.h rubyio.h st.h
prec.@OBJEXT@: prec.c ruby.h config.h defines.h intern.h
math.@OBJEXT@: math.c ruby.h config.h defines.h intern.h
numeric.@OBJEXT@: numeric.c ruby.h config.h defines.h intern.h
object.@OBJEXT@: object.c ruby.h config.h defines.h intern.h st.h
pack.@OBJEXT@: pack.c ruby.h config.h defines.h intern.h
process.@OBJEXT@: process.c ruby.h config.h defines.h intern.h rubysig.h st.h
random.@OBJEXT@: random.c ruby.h config.h defines.h intern.h
range.@OBJEXT@: range.c ruby.h config.h defines.h intern.h
re.@OBJEXT@: re.c ruby.h config.h defines.h intern.h re.h regex.h
regex.@OBJEXT@: regex.c config.h regex.h util.h
ruby.@OBJEXT@: ruby.c ruby.h config.h defines.h intern.h dln.h util.h
signal.@OBJEXT@: signal.c ruby.h config.h defines.h intern.h rubysig.h
sprintf.@OBJEXT@: sprintf.c ruby.h config.h defines.h intern.h
st.@OBJEXT@: st.c config.h st.h
string.@OBJEXT@: string.c ruby.h config.h defines.h intern.h re.h regex.h
struct.@OBJEXT@: struct.c ruby.h config.h defines.h intern.h
time.@OBJEXT@: time.c ruby.h config.h defines.h intern.h
util.@OBJEXT@: util.c ruby.h config.h defines.h intern.h util.h
variable.@OBJEXT@: variable.c ruby.h config.h defines.h intern.h env.h node.h st.h
version.@OBJEXT@: version.c ruby.h config.h defines.h intern.h version.h
